package com.zhentao.feign;

import com.zhentao.api.schedule.ScheduleClientApi;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.schedule.dto.TaskDto;
import com.zhentao.service.TaskInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ScheduleClient implements ScheduleClientApi {

    @Autowired
    private TaskInfoService taskInfoService;

    @PostMapping("/api/v1/task/add")
    @Override
    public ResponseResult addTask(TaskDto taskDto) {
        return ResponseResult.okResult(taskInfoService.addTask(taskDto));
    }
    //按照类型和优先级来拉取任务
    @GetMapping("/api/v1/task/poll/{type}/{priority}")
    @Override
    public ResponseResult poll(int type, int priority) {
        return ResponseResult.okResult(taskInfoService.poll(type,priority));
    }
}
